package com.restaurant.application.consumption.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;
import com.nebutown.generation.basictype.UIDLists;

import java.util.List;

public class ConsumptionData implements PickableBean {

    public static final String FN_DISCOUNT = "discount";
    public static final String FN_SHOPUID = "shopUID";
    public static final String FN_SHOPID = "shopID";
    public static final String FN_ORDERID = "orderId";
    public static final String FN_TOTALPRICE = "totalPrice";
    public static final String FN_FINALPRICE = "finalPrice";
    public static final String FN_CUSTOMERNAME = "customerName";
    public static final String FN_CUSTOMER = "customer";
    public static final String FN_WECHATID = "weChatId";
    public static final String FN_TIME = "time";
    public static final String FN_PHONE = "phone";
    public static final String FN_ACCUMULATEPOINTS = "accumulatePoints";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_DISCOUNT,
            FN_SHOPUID,
            FN_SHOPID,
            FN_ORDERID,
            FN_TOTALPRICE,
            FN_FINALPRICE,
            FN_CUSTOMERNAME,
            FN_CUSTOMER,
            FN_WECHATID,
            FN_TIME,
            FN_PHONE,
            FN_ACCUMULATEPOINTS);
    
    private UIDLists discount;
    private UID shopUID;
    private String shopID;
    private String orderId;
    private Double totalPrice;
    private Double finalPrice;
    private String customerName;
    private UID customer;
    private String weChatId;
    private Long time;
    private String phone;
    private Long accumulatePoints;

    public ConsumptionData(UIDLists discount, UID shopUID, String shopID, String orderId, Double totalPrice, Double finalPrice, String customerName, UID customer, String weChatId, Long time, String phone, Long accumulatePoints) {
        setDiscount(discount);
        setShopUID(shopUID);
        setShopID(shopID);
        setOrderId(orderId);
        setTotalPrice(totalPrice);
        setFinalPrice(finalPrice);
        setCustomerName(customerName);
        setCustomer(customer);
        setWeChatId(weChatId);
        setTime(time);
        setPhone(phone);
        setAccumulatePoints(accumulatePoints);
    }

    public ConsumptionData() {
    }

    public ConsumptionData duplicate() {
        ConsumptionData result = new ConsumptionData();
        result.discount = this.discount == null ? null : this.discount.duplicate();
        result.shopUID = this.shopUID;
        result.shopID = this.shopID;
        result.orderId = this.orderId;
        result.totalPrice = this.totalPrice;
        result.finalPrice = this.finalPrice;
        result.customerName = this.customerName;
        result.customer = this.customer;
        result.weChatId = this.weChatId;
        result.time = this.time;
        result.phone = this.phone;
        result.accumulatePoints = this.accumulatePoints;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public UIDLists getDiscount() {
        if (discount == null) {
            discount = new UIDLists();
        }
        return discount;
    }

    public void setDiscount(UIDLists value) {
        this.discount = value;
    }

    public ConsumptionData withDiscount(UIDLists value) {
        setDiscount(value);
        return this;
    }

    public ConsumptionData withDiscount(UIDLists value, UIDLists defaultValue) {
        setDiscount(value == null ? defaultValue : value);
        return this;
    }

    public UID getShopUID() {
        return shopUID;
    }

    public void setShopUID(UID value) {
        this.shopUID = value;
    }

    public ConsumptionData withShopUID(UID value) {
        setShopUID(value);
        return this;
    }

    public ConsumptionData withShopUID(UID value, UID defaultValue) {
        setShopUID(value == null ? defaultValue : value);
        return this;
    }

    public String getShopID() {
        return shopID;
    }

    public void setShopID(String value) {
        this.shopID = value;
    }

    public ConsumptionData withShopID(String value) {
        setShopID(value);
        return this;
    }

    public ConsumptionData withShopID(String value, String defaultValue) {
        setShopID(value == null ? defaultValue : value);
        return this;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String value) {
        this.orderId = value;
    }

    public ConsumptionData withOrderId(String value) {
        setOrderId(value);
        return this;
    }

    public ConsumptionData withOrderId(String value, String defaultValue) {
        setOrderId(value == null ? defaultValue : value);
        return this;
    }
    
    public Double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Double value) {
        this.totalPrice = value;
    }

    public ConsumptionData withTotalPrice(Double value) {
        setTotalPrice(value);
        return this;
    }

    public ConsumptionData withTotalPrice(Double value, Double defaultValue) {
        setTotalPrice(value == null ? defaultValue : value);
        return this;
    }
    
    public Double getFinalPrice() {
        return finalPrice;
    }

    public void setFinalPrice(Double value) {
        this.finalPrice = value;
    }

    public ConsumptionData withFinalPrice(Double value) {
        setFinalPrice(value);
        return this;
    }

    public ConsumptionData withFinalPrice(Double value, Double defaultValue) {
        setFinalPrice(value == null ? defaultValue : value);
        return this;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String value) {
        this.customerName = value;
    }

    public ConsumptionData withCustomerName(String value) {
        setCustomerName(value);
        return this;
    }

    public ConsumptionData withCustomerName(String value, String defaultValue) {
        setCustomerName(value == null ? defaultValue : value);
        return this;
    }
    
    public UID getCustomer() {
        return customer;
    }

    public void setCustomer(UID value) {
        this.customer = value;
    }

    public ConsumptionData withCustomer(UID value) {
        setCustomer(value);
        return this;
    }

    public ConsumptionData withCustomer(UID value, UID defaultValue) {
        setCustomer(value == null ? defaultValue : value);
        return this;
    }

    public String getWeChatId() {
        return weChatId;
    }

    public void setWeChatId(String value) {
        this.weChatId = value;
    }

    public ConsumptionData withWeChatId(String value) {
        setWeChatId(value);
        return this;
    }

    public ConsumptionData withWeChatId(String value, String defaultValue) {
        setWeChatId(value == null ? defaultValue : value);
        return this;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long value) {
        this.time = value;
    }

    public ConsumptionData withTime(Long value) {
        setTime(value);
        return this;
    }

    public ConsumptionData withTime(Long value, Long defaultValue) {
        setTime(value == null ? defaultValue : value);
        return this;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String value) {
        this.phone = value;
    }

    public ConsumptionData withPhone(String value) {
        setPhone(value);
        return this;
    }

    public ConsumptionData withPhone(String value, String defaultValue) {
        setPhone(value == null ? defaultValue : value);
        return this;
    }
    
    public Long getAccumulatePoints() {
        return accumulatePoints;
    }

    public void setAccumulatePoints(Long value) {
        this.accumulatePoints = value;
    }

    public ConsumptionData withAccumulatePoints(Long value) {
        setAccumulatePoints(value);
        return this;
    }

    public ConsumptionData withAccumulatePoints(Long value, Long defaultValue) {
        setAccumulatePoints(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "discount":
                return getDiscount();
            case "shopUID":
                return getShopUID();
            case "shopID":
                return getShopID();
            case "orderId":
                return getOrderId();
            case "totalPrice":
                return getTotalPrice();
            case "finalPrice":
                return getFinalPrice();
            case "customerName":
                return getCustomerName();
            case "customer":
                return getCustomer();
            case "weChatId":
                return getWeChatId();
            case "time":
                return getTime();
            case "phone":
                return getPhone();
            case "accumulatePoints":
                return getAccumulatePoints();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ConsumptionData)) return false;
        return signature().equals(((ConsumptionData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ConsumptionData has no signature defined, no hash code or equals possible.");
    }
}
